/**
 * $Id: Commandline.java 19 2006-09-16 20:29:16Z willi.w $
 */
package at.wwu.tunes2db.types;

import java.util.Hashtable;

import org.apache.log4j.Logger;


/**
 * @author willi.w
 * Album information 
 */
public class Album extends Element {

    private static final Logger log = Logger.getLogger(Album.class.getName());

    private static final Hashtable<String, Album> albums = new Hashtable<String, Album>();

    Album(String new_name) {
        super(new_name);
    }

    public static Album add(String name) {
        if (albums.containsKey(name.trim())) {            
            instance = albums.get(name.trim());
            instance.isNew = false;
        } else {            
            instance = new Album(name.trim());
            instance.isNew = true;
            albums.put(name.trim(), (Album) instance);
            //log.debug("Album.add("+ (instance.isNew?"new ":"") + name + ")");
        }        
        return (Album) instance;
    }

    @Override
    public String toString() {
        return "Album " + id + ": " + name;
    }
}
